import request from './request'
import { useUserStore } from '../store/modules/user'
// 获取工单配件列表
export function spareWork(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/getList',
    method: 'post',
    headers: token,
    data,
  })
}
// 审核工单配件
export function checkOrderSpare(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/checkOrderSpare',
    method: 'put',
    headers: token,
    data,
  })
}

// 根据工单配件ID获取工单配件详情
export function OrderSpareDetailProjectInfo(id: string) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/getDetail/' + id,
    method: 'get',
    headers: token,
  })
}
//根据工单ID获取工单详情的工单配件列表
export function getOrderDetailWorkSpareList(data: any, workId: string | string[]) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/getOrderDetailWorkSpareList/' + workId,
    method: 'post',
    headers: token,
    data,
  })
}
// 根据工单ID获取工单客户地址
export function getWorkUserAddress(workId) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/user/getWorkUserAddress/' + workId,
    method: 'get',
    headers: token,
  })
}

// 根据工单ID获取服务商地址
export function getOrderNetworkAddress(workId) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/order/getOrderNetworkAddress',
    method: 'get',
    headers: token,
    params: { workId },
  })
}

// 保存或修改工单配件
export function spareSaveOrder(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/save',
    method: 'post',
    headers: token,
    data,
  })
}

// 根据工单配件ID获取工单配件详情的物料信息
export function getOrderSpareMaterial(id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/getOrderSpareMaterial/' + id,
    method: 'get',
    headers: token,
  })
}

// 获取审核前的工单配件信息
export function getBeforeCheckOrderSpareDetail(id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/getBeforeCheckOrderSpareDetail/' + id,
    method: 'get',
    headers: token,
  })
}
// 获取工单配件日志列表
export function OrderSpareLogList(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/getOrderSpareLogList/' + id,
    method: 'post',
    headers: token,
    data,
  })
}
// 获取工单配件旧件列表
export function getBackList(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/work/spare/return/getList',
    method: 'post',
    headers: token,
    data,
  })
}
